package org.jianghu.activity.user;

import android.app.Activity;
import android.util.Log;

import com.avos.avoscloud.AVException;
import com.avos.sns.SNS;
import com.avos.sns.SNSBase;
import com.avos.sns.SNSCallback;
import com.avos.sns.SNSException;
import com.avos.sns.SNSType;

import org.jianghu.activity.user.login.model.OtherModel;

/**
 * Created by Administrator on 2016/12/20.
 * 第三方登录
 */

public class OtherPresenterCompl implements OtherLogin {

    OtherLoginView otherLoginView;

    public Activity context;

    public OtherPresenterCompl(OtherLoginView otherLoginView,Activity context){
        this.otherLoginView = otherLoginView;
        this.context = context;
    }

    @Override
    public void qqLogin() {
        SNSCallback snsCallback = new SNSCallback() {
            @Override
            public void done(SNSBase snsBase, SNSException e) {
                if(e == null){
                    otherLoginView.resultQqLogin(true);
                    //登陆成功
                    Log.i("JH","--loginok-->" + SNSType.AVOSCloudSNSQQ);
                }else{
                    //登陆失败
                    otherLoginView.resultQqLogin(false);
                }
            }
        };
        try {
            SNS.setupPlatform(context, SNSType.AVOSCloudSNSQQ, OtherModel.QQ_APP_ID,"",OtherModel.QQ_SECRET_KEY);
            SNS.loginWithCallback(context,SNSType.AVOSCloudSNSQQ,snsCallback);
        } catch (AVException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void sinaLogin() {

    }
}
